<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 微信会员卡-会员列表
 */
class WxCardMemberList extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //微信卡券会员卡-会员列表
        Schema::create('wx_card_member_lists', function (Blueprint $table) {
            $table->increments('id')->comment('自增序号');
            $table->unsignedInteger('card_base_id')->default(0)->comment('卡券主键唯一ID');
            $table->string('card_id', 200)->default('')->comment('微信卡券ID');
            $table->string('user_card_code', 200)->default('')->comment('code序列号');
            $table->string('openid', 100)->default('')->comment('领券用户openid');
            $table->string('nickname', 100)->default('')->comment('用户昵称');
            $table->string('sex', 200)->default('')->comment('二维码名称');
            $table->string('bonus', 50)->default('')->comment('积分信息');
            $table->string('balance', 50)->default('')->comment('余额信息');
            $table->unsignedInteger('level_id')->default(0)->comment('会员等级ID');
            $table->string('level_key', 50)->default('')->comment('会员等级标识');
            $table->string('level_name', 100)->default('')->comment('会员等级名称');
            $table->text('user_info')->nullable()->comment('会员信息');
            $table->string('user_card_status', 50)->default('')->comment('当前用户的会员卡状态');
            $table->unsignedTinyInteger('has_active')->default(0)->comment('该卡是否已经被激活');
            $table->charset = 'utf8';
            $table->collation = 'utf8_unicode_ci';
            $table->softDeletes();
            $table->timestamps();
            $table->index(['user_card_code','card_id','deleted_at'], 'index1');
            $table->index(['card_base_id','level_id','deleted_at'], 'index2');
            $table->index(['openid','card_id','deleted_at'], 'index3');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wx_card_member_lists');
    }
}
